
package com.marketapp.validators;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

import com.marketapp.domain.Equity;
import com.marketapp.helper.ServiceException;
import com.marketapp.service.IEquityService;
import com.marketapp.util.StringUtil;

@Component
public class EquitySearchValidator implements Validator{

	@Override
	public boolean supports(Class<?> clazz) {
		return Equity.class.isAssignableFrom(clazz);
	}
	
	@Autowired
	IEquityService equityService;

	public IEquityService getEquityService() {
		return equityService;
	}

	public void setEquityService(IEquityService equityService) {
		this.equityService = equityService;
	}

	@Override
	public void validate(Object target, Errors errors) {
		ValidationUtils.rejectIfEmpty(errors, "equityName", "equity.required");
	}

}
